import type { AddressParams, AddressResult } from '@/types/address'
import { http } from '@/utils/https'

export const postMemberAddressAPI = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: '/member/address',
    data,
  })
}

export const getAddressAPI = () => {
  return http<AddressResult[]>({
    url: '/member/address',
  })
}

export const getAddressDetailAPI = (id: string) => {
  return http<AddressResult>({
    url: `/member/address/${id}`,
  })
}

export const putAddressDetailAPI = (data: AddressParams & { id: string }) => {
  return http({
    method: 'PUT',
    url: `/member/address/${data.id}`,
    data,
  })
}

export const deleteAddressAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
